{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <!-- 表单头部 -->
                <div class="card-header">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fas fa-arrow-left"></i>
                            返回
                        </a>
                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post" enctype="multipart/form-data">
                    <!-- 表单字段区域 -->
                    <div class="card-body">
                        <div class="form-group row rowSelect">
    <label for="project_id" class="col-sm-2 col-form-label">项目</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="project_id" id="project_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择项目">
            <option value=""></option>
            {foreach name='project_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.project_id==$item.id}selected{/if}>
        {$item.title}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#project_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row rowSelect">
    <label for="user_id" class="col-sm-2 col-form-label">公司</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="user_id" id="user_id" class="form-control select2bs4 fieldSelect" data-placeholder="请选择公司">
            <option value=""></option>
            {foreach name='user_list' id='item'}
    <option value="{$item.id}" {if isset($data) && $data.user_id==$item.id}selected{/if}>
        {$item.username}
    </option>
{/foreach}
        </select>
    </div>

    <script>
        $('#user_id').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>
<div class="form-group row">
                            <label class="col-sm-2 col-form-label ">报价</label>
                            <div class="col-sm-10 col-md-10">
                                <table id="settingSetting" class="table table-hover table-bordered datatable"
                                       width="100%">
                                    <thead>
                                    <tr class="input-type">
                                        
                                        <th>名称</th>
                                        <th>规格</th>
                                        <th>数量</th>
                                        <th>最高报价</th>
                                        <th>报价</th>
                                    </tr>
                                    </thead>
                                    <tbody id="dataBody">
                                    {if isset($data)}
                                    {foreach name='data.detail' id='item'}
                                    <tr>
                                        

                                        

                                        <td>
                                            <input class="form-control" placeholder="名称" value="{$item.name|default=''}"
                                                   maxlength="50"   name="config_name[]">

                                        </td>
                                        <td>
                                            <!-- <input class="form-control" placeholder="规格" value="{$item.spec|default=''}"
                                                   maxlength="50"   name="config_spec[]"> -->
                                            <select name="config_spec[]" class="form-control">
                                                <option value="text" {if $item.spec=='text'}selected{/if}>
                                                    文本[text]
                                                </option>
                                            </select>
                                        </td>
                                        <td>
                                            <input class="form-control" placeholder="数量" value="{$item.num|default=''}"
                                                   maxlength="50"   name="config_num[]">

                                        </td>
                                        <td>
                                            <input class="form-control" placeholder="最高报价" value="{$item.price|default=''}"
                                                   maxlength="50"   name="config_price[]">
                                        </td>
                                        <td>
                                            <input class="form-control" placeholder="报价" value="{$item.money|default=''}"
                                                   maxlength="50"   name="config_money[]">

                                        </td>
                                    </tr>
                                    {/foreach}
                                    {/if}
                                    </tbody>
                                </table>
                            </div>
                        </div>
<div class="form-group row rowSelect">
    <label for="status" class="col-sm-2 col-form-label">状态</label>
    <div class="col-sm-10 col-md-4 formInputDiv">
        <select name="status" id="status" class="form-control select2bs4 fieldSelect" data-placeholder="请选择状态">
            <option value=""></option>
                    {foreach status_list as $key=>$value}
        <option value="{$key}" {if isset($data) && $data.status==$key}selected{/if}>{$value}</option>
        {/foreach}



        </select>
    </div>

    <script>
        $('#status').select2({
            theme: 'bootstrap4'
        });
    </script>
</div>

                    </div>
                    <!-- 表单底部 -->
                    <div class="card-footer">
                        <div class="row">
                            <div class="col-sm-2">
                            </div>

                            <div class="col-sm-10 col-md-4 formInputDiv">

                                <div class="btn-group">
                                    <button type="submit" class="btn btn-sm btn-primary dataFormSubmit">
                                        保 存
                                    </button>
                                </div>
                                <div class="btn-group">
                                    <button type="reset" class="btn btn-sm btn-default dataFormReset">
                                        重 置
                                    </button>
                                </div>

                                {if !isset($data)}
                                <div class="btn-group float-right createContinueDiv">
                                    <input type="checkbox" class="form-check-input" value="1" id="_create" name="_create" title="继续添加数据">
                                    <label class="form-check-label" for="_create">继续添加</label>
                                </div>
                                {/if}
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<table>
    <tbody id="data-template" style="display: none">
    <tr>
        
        
        <td>
            <input class="form-control" placeholder="名称" name="config_name[]">

        </td>
        <td>
            
            <select name="config_spec[]" class="form-control">
                <option value="text" {if $item.type=='text'}selected{/if}>
                    文本[text]
                </option>
            </select>
        </td>
        <td>
            <input class="form-control" placeholder="数量" name="config_num[]">

        </td>
        <td>
            <input class="form-control" placeholder="最高报价" name="config_price[]">

        </td>
        <td>
            <input class="form-control" placeholder="报价" name="config_money[]">

        </td>
    </tr>

    </tbody>
</table>
<script>
    /** 表单验证 **/
    $('#dataForm').validate({
        rules: {
                'project_id': {
                required: true,

    },
    'user_id': {
                required: true,

    },
    
    'status': {
                required: true,

    },

        },
        messages: {
                'project_id': {
               required: "项目不能为空",

    },
    'user_id': {
               required: "公司不能为空",

    },
    
    'status': {
               required: "状态不能为空",

    },

        }
    });
    
</script>

<script>
    $('#dataBody select').select2();
</script>
{/block}